[#include "/includes/_layout.html"/]
[@layout]
<div class="wrapper wrapper-content">
	<div class="row animated fadeInLeft">
	
	[#include "/includes/menus-setting.html" /]
	
	<div class="col-sm-11">
		<div class="row content-tabs">
			<nav class="page-tabs J_menuTabs">
		       <div class="page-tabs-content" style="margin-left: 0px;">
			       <a href="${webctx}/setting/xiaocx" class="J_menuTab active">小程序</a>
		       </div>
		   	</nav>
		</div>
		<div class="ibox float-e-margins col-sm-9">
			[#if error??]
			<div class="alert alert-danger">
				<button type="button" class="close" data-dismiss="alert">×</button>
				<strong>错误!</strong> ${error}.
			</div>
			[/#if]
			<div class="row ibox-content">
				<form id="weappForm" action="${webctx}/setting/saveWeapp" method="post" class="form-horizontal" style="padding-top: 10px;">
					<div>
						<input type="hidden" id="sel_app_id" name="id" value="${weapp.id}"/>
						<div class="form-group">
				            <label class="col-md-2 control-label">小程序appid</label>
				            <div class="col-md-5" id="error_app_id">
				                <input type="text" id="weapp_id" name="weapp_id" class="form-control" value="${weapp.weapp_id}"/>
				                <label class="control-label" for="weapp_id"></label>
				            </div>
				        </div>
				        <div class="form-group">
				            <label class="col-md-2 control-label">小程序appSecret</label>
				            <div class="col-md-5" id="error_pay_mch_id">
				                <input type="text" id="weapp_secret" name="weapp_secret" class="form-control" value="${weapp.weapp_secret}"/>
				                <label class="control-label" for="weapp_secret"></label>
				            </div>
				        </div>
					</div>
					<div class="panel-default">
					  	<div class="panel-body" align="center">
							<button type="submit" class="btn btn-success btn-sm">保存</button>
					  	</div>
				  	</div>
			  	</form>
		  	</div>
		</div>
		<div class="col-sm-3">
	         <div class="wrapper wrapper-content project-manager">
	             <h4>帮助说明</h4>
	             <ol>
	                 <li>打包小程序，并提交到微信审核</li>
	                 <li>选择不同的模板，会有对应的小程序功能</li>
	             </ol>
	         </div>
	     </div>	
	</div>
</div>
</div>
[/@layout]
<script type="text/javascript">
$().ready(function() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#weappForm").validate({
		//debug:true,
		errorElement: "em",
	    success: function(em) {
	        em.text("").addClass("success");//验证通过的动态CSS
	    },
	    submitHandler:function() {
	    	$("#weappForm").mask("正在保存...");
	    	$.post(obz.ctx+"/setting/saveWapp", $("#weappForm").serialize(), function(json) {
	    		$("#weappForm").unmask();
				if(json.code!=200){
					obz.error(json.msg);
				}else{
					obz.msg('保存成功', function(){
						location.href="${webctx}/setting/xiaocx"
					});					
				}
			},"json");
	    },
	    rules: {
	    	weapp_id: "required", weapp_secret: "required"
	    },
	    messages: {
	    	weapp_id: icon + "请输入appId", weapp_secret: icon + "请输入appSecret"
	    }
	});
})
</script>
<script type="text/javascript">
Template.init("#menu-setting");
Template.initSecond("#menu-routine");
</script>